package com.gem.day12;

import java.util.*;

import com.gem.day11.homework.Card;
import com.gem.day11.homework.Poker;

/**
 * 本类用来演示Java集合工具类
 * 
 * @author easonsy
 * 2020年8月3日 上午8:41:24
 */
public class CollectionsDemo {
	public static void main(String[] args) {
		Poker poker = new Poker();
		List<Card> cards = poker.getCards();
		//随机打乱顺序
		Collections.shuffle(cards);

		//反转集合元素顺序
		//Collections.reverse(cards);

		//按照指定规则排序
		Collections.sort(cards, new Comparator<Card>() {
			@Override
			public int compare(Card c1, Card c2) {
				return c1.getRank().compareTo(c2.getRank());
			}
		});

		//JDK8.0 lambda方式
		//Collections.sort(cards, (c1, c2) -> c1.getRank().compareTo(c2.getRank()));
		cards.forEach(System.out::println);
	}
}

/*Collection和Collections
 方法重载和重写
StringBuilder和StringBuffer
ArrayList和Vector
RuntimeException和Exception
Exception和Error
Array和Arrays*/
